<template>
  <div class='infinite-container'>
    <div class='bgwhite' v-if="lists.length > 0">
    <div class="fee-main">
      <mu-list>
        <template v-for="(list, i) in lists">
          <mu-list-item  @click="itemClick(list)" :key="i">
            <mu-flexbox>
              <mu-flexbox-item>{{list.patientName}}</mu-flexbox-item>
              <mu-flexbox-item :grow="2">{{list.departmentName}}</mu-flexbox-item>
              <mu-flexbox-item :grow="2">{{list.visitDate}}</mu-flexbox-item>
              <mu-flexbox-item v-if="list.isReply === '2'" class="text-right"><a href="javascript:;">回答</a></mu-flexbox-item>
              <mu-flexbox-item v-else class="text-right t3">已参与</mu-flexbox-item>
            </mu-flexbox>
            <mu-icon value=":iconfont icon-small-arrow-right" slot="right"/>
          </mu-list-item>
          <mu-divider class="" :key="i"/>
        </template>
      </mu-list>
    </div>
  </div>

  <div v-else>
    <div class="not-found">
      <div>暂无数据</div>
  </div>
  </div>
  </div>
</template>

<script>
import {commonAjax, RESTFUL_API} from '@/api/api'

export default {
  data () {
    return {
      requestMethod: 'listMedicalRecords',
      person: JSON.parse(sessionStorage.person || '{}'),
      lists: []
    }
  },
  mounted () {
    if (this.$route.params.id === '2') {
      this.requestMethod = 'getHospitalizationRecords'
    }
    this.getData(this.requestMethod)
  },
  methods: {
    itemClick (list) {
      if (list.isReply === '1') {
        // todo
        return
      }
      sessionStorage.currentQuestionnaire = JSON.stringify(list)
      this.$router.push(`/questionnaire/answer?type=${this.$route.params.id}`)
    },
    getData (method) {
      let params = {
        patientMedicalCardType: '',
        patientMedicalCardNumber: '',
        patientCode: '',
        patientIdentityCardType: this.person.cardtype || 1,
        patientIdentityCardNumber: this.person.idcard || 1
      }
      this.$store.commit('UPDATE_LOADING')
      commonAjax(RESTFUL_API[method], params, true).then(res => {
        this.$store.commit('UPDATE_LOADING')
        if (res.data.code === 1) {
          this.lists = res.data.data
        }
      })
    }
  }
}
</script>

<style>

</style>
